<template>
  <div>
<!--    排班form表单-->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="计划编号" prop="name">
        <el-input
          v-model="queryParams.planCode"
          placeholder="请输入作物名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计划名称" prop="planName">
        <el-input
          v-model="queryParams.planName"
          placeholder="请输入计划名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="班组类型" prop="name">
        <el-select v-model="queryParams.typeId" placeholder="请选择班组类型" clearable>
          <el-option
            v-for="dict in dict.type.sys_class_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"></el-option>
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
<!--排班上面按钮操作-->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['crop:products:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['crop:products:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['crop:products:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:dict:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
<!--    排班计划表-->
    <el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="计划id"  width="100px" align="center" prop="planId" />
      <el-table-column label="批次编码"  width="100px" align="center" prop="materialCode" />
      <el-table-column label="计划编码"  width="100px" align="center" prop="planCode" />
      <el-table-column label="计划名称" width="100px" align="center" prop="planName" />

      <el-table-column label="班组类型"  width="100px" align="center" prop="typeId">
        <template v-slot="scope">
          <dict-tag :options="dict.type.sys_class_type" :value="scope.row.typeId"/>
        </template>
      </el-table-column>

      <el-table-column label="起始时间" align="center" prop="beginTime">
        <template v-slot="scope">
          <span v-if="scope.row.beginTime">{{ parseTime(scope.row.beginTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" align="center" prop="endTime">
        <template v-slot="scope">
          <span v-if="scope.row.endTime">{{ parseTime(scope.row.endTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="轮班方式" align="aroundId" prop="aroundId">
      <template v-slot="scope">
       <span v-if="scope.row.aroundId === 0">
         白班
       </span>
        <span v-if="scope.row.aroundId === 1">
         轮班到
       </span>
        <span v-if="scope.row.aroundId === 2">
         三班倒
       </span>
      </template>
      </el-table-column>
      <el-table-column label="倒班方式" align="center" prop="wayId" >
        <template v-slot="scope">
          <dict-tag :options="dict.type.sys_shift_way" :value="scope.row.wayId"/>
        </template>
      </el-table-column>
      <el-table-column label="单据状态" align="center" prop="documentStatus">
        <template v-slot="s">
          <el-button size="mini" type="primary" v-if="s.row.documentStatus==0">草稿</el-button>
          <el-button size="mini" type="primary" v-if="s.row.documentStatus==1">已确认</el-button>
          <el-button size="mini" type="primary" v-if="s.row.documentStatus==2">加工完成</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['crop:products:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['crop:products:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加排班主对话框 -->
    <el-dialog :title="title"  :visible.sync="dialogFormVisiblel" width="1000px" append-to-body>
      <el-form  :model="form" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="计划编号" prop="name">
              <el-input v-model="uuidCode" placeholder="请输入计划编号" />
              <el-switch
                v-model="flaging"
                active-text="自动生成">
              </el-switch>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划名称" prop="name">
              <el-input v-model="form.planName" placeholder="请输入计划名称" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="批次编号" prop="materialLotId">
              <el-select v-model="form.materialLotId" placeholder="批次编号">
                <el-option
                  v-for="item in materialLots"
                  :key="item.materialLotId"
                  :label="item.materialCode"
                  :value="item.materialLotId">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="班组类型" >
              <el-select v-model="form.typeId" placeholder="请选择班组类型" clearable>
                <el-option
                  v-for="dict in dict.type.sys_class_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="计划开始时间" prop="name">
              <el-date-picker
                v-model="createTimes"
                type="datetimerange"
                value-format="yyyy-MM-dd HH:mm:ss"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="轮班方式" >
              <el-radio-group v-model="form.aroundId">
                <el-radio :label="0">白班</el-radio>
                <el-radio :label="1">夜班</el-radio>
                <el-radio :label="2">中班</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="倒班方式" >
              <el-select v-model="form.wayId" placeholder="请选择倒班方式" clearable>
                <el-option
                  v-for="dict in dict.type.sys_shift_way"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" >
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisiblel = false">取 消</el-button>
        <el-button type="primary" @click="addForm">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 结束加排班主对话框 -->


    <!--修改排班对话框 -->
    <el-dialog :title="title"  :visible.sync="dialogFormVisible" width="1500px" append-to-body>
      <el-form  :model="form" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="批次编号" prop="materialLotId">
              <el-select v-model="form.materialLotId" placeholder="批次编号">
                <el-option
                  v-for="item in materialLots"
                  :key="item.materialLotId"
                  :label="item.materialCode"
                  :value="item.materialLotId">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="计划编号" prop="name">
              <el-input v-model="uuidCode" placeholder="请输入计划编号" />
              <el-switch
                v-model="flaging"
                active-text="自动生成">
              </el-switch>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划名称" prop="name">
              <el-input v-model="form.planName" placeholder="请输入计划名称" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="班组类型" >
              <el-select v-model="form.typeId" placeholder="请选择班组类型" clearable>
                <el-option
                  v-for="dict in dict.type.sys_class_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="计划开始时间" prop="name">
              <el-date-picker
                v-model="createTimes"
                type="datetimerange"
                value-format="yyyy-MM-dd HH:mm:ss"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="轮班方式" >
              <el-radio-group v-model="form.aroundId">
                <el-radio :label="0">白班</el-radio>
                <el-radio :label="1">夜班</el-radio>
                <el-radio :label="2">中班</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="倒班方式" >
              <el-select v-model="form.wayId" placeholder="请选择倒班方式" clearable>
                <el-option
                  v-for="dict in dict.type.sys_shift_way"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" >
              <el-input v-model="form.remark" placeholder="请输入备注" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <span style="color: #8c939d">-----------------班次----------------------</span>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="AddAround"
              v-hasPermi="['crop:around:add']"
            >新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              plain
              icon="el-icon-edit"
              size="mini"
              :disabled="single"
              @click="UpdateAround"
              v-hasPermi="['crop:around:edit']"
            >修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="DeleteAround"
              v-hasPermi="['crop:around:remove']"
            >删除</el-button>
          </el-col>
          <el-col :span="1.5">
          </el-col>
          <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>



        <el-table v-loading="loading" :data="banciLists" @selection-change="handleSelectionChanges">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="班次id"  width="100px" align="center" prop="id" />
          <el-table-column label="班次名称"  width="100px" align="center" prop="aroundName" />
          <el-table-column label="开始时间"  width="100px" align="center" prop="beginTime" >
          </el-table-column>
          <el-table-column label="结束时间"  width="100px" align="center" prop="endTime" >
          </el-table-column>
          <el-table-column label="备注"  width="100px" align="center" prop="remark" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="UpdateAround(scope.row)"
                v-hasPermi="['crop:products:edit']"
              >修改</el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="DeleteAround(scope.row)"
                v-hasPermi="['crop:products:remove']"
              >删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryAround.pageNum"
          :limit.sync="queryAround.pageSize"
          @pagination="getByAroundListPage"
        />


      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
<!--        <el-button ref="teamSelect" type="success" @click="successForm">完 成</el-button>-->
        <el-button ref="teamSelect" type="primary" @click="updateForm">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 结束排班对话框 -->


    <!-- 添加班次对话框 -->
    <el-dialog :title="title" :visible.sync="dialogFormVisibles" width="1000px" append-to-body >
      <el-form  :model="formAround" label-width="100px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="班次名称" prop="name">
              <el-input v-model="formAround.aroundName" placeholder="请输入班次名称" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="开始时间" prop="startTime">
              <el-time-picker
                v-model="formAround.beginTime"
                placeholder="请选择开始时间"
                format ="HH:mm"
                value-format="HH:mm"
              >
              </el-time-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结束时间" prop="endTime">
              <el-time-picker
                v-model="formAround.endTime"
                placeholder="请选择结束时间"
                format ="HH:mm"
                value-format="HH:mm"
              >
              </el-time-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <span v-if="formAround.id!=null">
        <el-row :gutter="10" class="mb8">
          <el-col :span="7">
            <span style="color: #8c939d">班组------------------------</span>
            <el-button
              v-model="toTeammember"
              type="primary"
              plain
              icon="el-icon-plus"
              size="mini"
              @click="openAddTeam"
              v-hasPermi="['crop:team:add']"
            >新增</el-button>
            <el-table v-loading="loading" :data="marketLists" @selection-change="handleSelectionChangeAll">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="班组id" align="center" prop="teamId" />
              <el-table-column label="班组名称" align="center" prop="teamName" />
            </el-table>
          </el-col>
          <br>

          <el-col :span="7">
            <span>成员</span>
            <el-table v-loading="loading" :data="UserList" @selection-change="handleSelectionChangeAll">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="用户名称" align="center" key="userName" prop="userName"/>
              <el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" />
              <el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" />
            </el-table>
          </el-col>
        </el-row>
        </span>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisibles = false">取 消</el-button>
        <el-button type="primary" @click="sumArounds">确 定</el-button>
      </div>
    </el-dialog>
    <!-- 结束班次对话框 -->


    <!-- 添加班组对话框 -->
    <el-dialog :title="title" :visible.sync="dialogFormVisibleBanzu"  width="1000px" append-to-body>
      <Teammember :team="team" />
    </el-dialog>
    <!-- 结束班组对话框 -->
  </div>
</template>

<script>
import {
  listCrop,
  getPlan,
  delCrop,
  addCrop,
  updateCrop,
  AroundLists,
  MarketList,
  successBan
} from "@/api/scheduling/plan";
import {selectMaterialCode} from "@/api/scheduling/plan";
import {
  addAround,
  updateAround,getAround,AroundListPage,delAround} from "@/api/scheduling/around";
import Teammember from "./Teammember";
import {getMaterialLotList} from "@/api/product/products";
export default {
  components: {Teammember},
  name: "index",
  dicts: ['sys_class_type','sys_shift_way'],
  watch:{
    flaging(val){
      if(val){
        this.getMaterialCode();
      }
    },
    team:{
      if(team){
        console.log(team,"监听")
      }
    }
  },
  data() {
    return {
      banzu:{
        id:undefined,
        aroundId: undefined,
      },
      banziId:undefined,
      team:[],
      //班组单列表查询
      marketLists:[],
      toTeammember:"Teammember",
      //班次时间范围
      aroundTime:[],
      //添加班组
      formAround:{},
      //班次列表+分页
      banciLists:[],
      materialLots:[],
      //班次列表
      banciList:[],
      showList:'',
      //轮班数组
      arounds:[],
      around:'',
      //倒班数组
      ways:[],
      flaging:false,
      uuidCode:undefined,
      planList:[],
      createTimes:[],
      teams:[],
      loading: true,
      dialog: false,
      ids: [],
      single: true,
      multiple: true,
      showSearch: true,
      table: false,
      total: 0,
      title: "",
      dialogFormVisibleBanzu:false,
      dialogFormVisiblel:false,
      //班次对话框
      dialogFormVisibles:false,
      dialogFormVisible: false,
      queryAround:{
        aroundId:undefined,
        planId:undefined,
        pageNum: 1,
        pageSize: 10,
      },
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
      },
      form: {},
      options: [],
    };
  },
  methods: {
    /** 查询批次号列表 */
    selectMaterialLotList(){
      getMaterialLotList().then(response => {
        this.materialLots = response.data;
      });
    },
    handleExport(){
      window.location.href="http://localhost:9222/plan/exportToExcel";
    },
    // successForm() {
    //   this.$modal.confirm('是否完成计划编制？【完成后将不能更改】').then(() => {
    //       // 确认完成操作后的逻辑
    //
    //       return successBan(this.form); // 返回一个 promise，以便链式处理
    //   }).then(response => {
    //     // successBan 成功执行后的逻辑
    //     this.$message.success(response.msg);
    //     this.dialogFormVisible = false;
    //     this.getList();
    //   }).catch(() => {
    //     // 捕获任何错误或者取消操作的情况
    //     this.$modal.error("班组数据不能为空");
    //   });
    // },
    openAddTeam(){
      console.log(this.banzu,"你好")
      // 如果 this.team 没有定义为数组，需要先初始化为空数组
      if (!Array.isArray(this.team)) {
        this.team = [];
      }
      // 将 id 和 aroundId 添加到 this.team 中
      this.team.push({ id: this.banzu.id, aroundId: this.banzu.aroundId });
      console.log(this.id,this.aroundId,this.team,"你好")
      console.log(JSON.stringify(this.team)+":成功吧")
      this.dialogFormVisibleBanzu=true;
    },
    //班组列表
    getMarket(){
      console.log(JSON.stringify(this.banzu)+":挂机中");
      MarketList(this.banzu).then(r=>{
         this.marketLists=r.data;
       })
    },
    /** 班次提交按钮 */
    sumArounds() {
      if (this.formAround.aroundId != null) {
         updateAround(this.formAround).then(r => {
          this.$modal.msgSuccess("修改成功");
          this.dialogFormVisibles = false;
          this.getByAroundListPage();
        });
      } else {
        console.log(this.banciList.length)
        this.getByAroundListPage();
        this.formAround.planId=this.form.planId;
        this.formAround.aroundType = this.form.aroundId;
        this.formAround.aroundSize = this.banciLists.length;
        addAround(this.formAround).then(r => {
          this.$modal.msgSuccess("新增成功");
          this.dialogFormVisibles = false;
          this.getByAroundListPage();
        });
      }
    },
    //计数器
    handleChange(value) {
      console.log(value);
    },
    /**班次删除按钮操作 */
    DeleteAround(row) {
      const teamId = row.id || this.ids;
      this.$modal.confirm('是否确认删除农作物编号为"' + teamId + '"的数据项？').then(function() {
        return delAround(teamId);
      }).then(() => {
        this.getByAroundListPage();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 班次新增按钮操作 */
    AddAround() {
      this.title = "添加班次";
      this.formAround={};
      this.dialogFormVisibles = true;
    },
    /** 班次修改按钮操作 */
    UpdateAround(row) {
      this.formAround= row;
      this.banzu.id = row.id;
      this.banzu.aroundId =row.aroundId;
      this.getMarket();
      console.log(JSON.stringify(this.banzu)+"dgfhgfjh")
      this.dialogFormVisibles = true;
      this.team[0].id=row.id;
      this.team[1].aroundId=row.aroundId;
      this.getMarket();
    },
    //轮班列表+分页
    getByAroundListPage() {
      console.log(this.queryAround+"gjhkj")
      AroundListPage(this.queryAround).then(r => {
        this.banciLists = r.rows;
        this.total = r.total;
      });
    },
    //轮班列表
    getByAroundList() {
      AroundLists().then(r => {
        this.banciList = r.data;

      });
    },
    //轮班类型
    getByAround() {
      AroundLists().then(r => {
        this.arounds = r.data;
        console.log(this.arounds);
      });
    },

    //自动生成编码
    getMaterialCode(){
      selectMaterialCode().then(r=>{
        this.uuidCode=r.msg;
      })
    },
    /** 查询排班计划列表 */
    getList() {
      this.loading = true;
      listCrop(this.queryParams).then(r => {
        this.planList = r.rows;
        this.total = r.total;
        this.loading = false;
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.handleQuery();
    },
    // 班组计划多选框选中数据
    handleSelectionChangeAll(selection) {
      this.ids = selection.map(item => item.teamId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    // 班次多选框
    handleSelectionChanges(selection){
      this.ids = selection.map(item => item.aroundId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    // 排班计划多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.cropId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 排班新增按钮操作 */
    handleAdd() {
      this.title = "添加排班";
      this.form={};
      this.selectMaterialLotList();
      this.dialogFormVisiblel = true;
    },
    /** 排班修改按钮操作 */
    handleUpdate(row) {
      this.queryAround.planId = row.planId;
      this.queryAround.aroundId=row.aroundId;
      this.selectMaterialLotList();
      console.log(this.queryAround.planId+"1232343")
      console.log(this.queryAround.aroundId+"567")
      this.title = "修改排班";
      this.form={};
      const planId = row.planId || this.ids ;
      console.log(planId);
      this.uuidCode=row.planCode;
      getPlan(planId).then(r => {
        this.form = r.data;
        this.form.typeId=row.typeId;
        this.form.wayId=row.wayId;
        this.createTimes[0]=this.form.beginTime;
        this.createTimes[1]=this.form.endTime;
        this.dialogFormVisible = true;
      });
      this.getByAroundListPage();
    },
    // 排班修改操作
    updateForm(){

        updateCrop(this.form).then(r => {
          this.$modal.msgSuccess("修改成功");
          this.dialogFormVisible = false;
          this.getList();
        });
    },
    //排班添加操作
    addForm(){
      this.form.beginTime=this.createTimes[0];
      this.form.endTime=this.createTimes[1];
      this.form.planCode=this.uuidCode;
      console.log(JSON.stringify(this.aroundId)+"2222")
      addCrop(this.form).then(r => {
        this.$modal.msgSuccess("新增成功");
        this.dialogFormVisiblel = false;
        this.getList();
      });
    },
    /**排班删除按钮操作 */
    handleDelete(row) {
      const ids = row.planId || this.ids;
      this.$modal.confirm('是否确认删除农作物编号为"' + ids + '"的数据项？').then(function() {
        return delCrop(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 提交按钮 */
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
      this.imageUrl=res;
      this.form.img=res;
      this.growForm.pic=res;
    },
  },
  created() {
    this.getList();
    this.getByAround();
    this.getByAroundList();
    this.getByAroundListPage();
  },
};
</script>
